package com.ztn.sdk.iot.api;

import com.fasterxml.jackson.core.type.TypeReference;
import com.ztn.sdk.iot.api.req.DeviceParamListReq;
import com.ztn.sdk.iot.api.res.BaseRes;
import com.ztn.sdk.iot.api.res.DeviceParam;
import com.ztn.sdk.iot.api.util.HttpTool;
import com.ztn.sdk.iot.api.util.JsonTool;

import java.util.ArrayList;
import java.util.List;

public class IotDeviceParamTool {

    private static final String BASE_PATH = "iot/api/v1/v1/device/param/";


    public static List<DeviceParam> list(DeviceParamListReq req) {
        String path = BASE_PATH + "list";
        BaseRes<List<DeviceParam>> res = HttpTool.doPost(path, JsonTool.toJson(req), new TypeReference<BaseRes<List<DeviceParam>>>() {
        });
        if (null != res && null != res.data) {
            return res.data;
        }
        return new ArrayList<>();
    }

}
